/*
 * =====================================================================================
 *
 *       Filename:  Contex.cc
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  01/04/2022 04:04:10 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  first_name last_name (fl), fl@my-company.com
 *        Company:  my-company
 *
 * =====================================================================================
 */

#include "Context.h"
#include   <stdio.h>
#include "Log.h"
#include <iostream>
using std::string;
static const string TAG = "Context";

OpenningState* Context::pOpenningState = NULL;
CloseingState* Context::pCloseingState = NULL;
RunningState* Context::pRunningState = NULL;
StoppingState* Context::pStoppingState = NULL;

Context::Context(void) {
    m_pLiftState = NULL;
    pOpenningState = new OpenningState();
    pCloseingState = new CloseingState();
    pRunningState = new RunningState();
    pStoppingState = new StoppingState();
}

Context::~Context(void) {
    delete pOpenningState;
    pOpenningState = NULL;
    delete pCloseingState;
    pCloseingState = NULL;
    delete pRunningState;
    pRunningState = NULL;
    delete pStoppingState;
    pStoppingState = NULL;
}

LiftState* Context::GetLiftState() {
    LogI("In");
    return m_pLiftState;
}

void Context::SetLiftState(LiftState* pLiftState) {
    LogI("In");
    this->m_pLiftState = pLiftState;
    this->m_pLiftState->SetContext(this);
}

void Context::Open() {
    LogI("In");
    this->m_pLiftState->Open();
}

void Context::Close() {
    LogI("In");
    this->m_pLiftState->Close();
}

void Context::Run() {
    LogI("In");
    this->m_pLiftState->Run();
}

void Context::Stop() {
    LogI("In");
    this->m_pLiftState->Stop();
}
